-
Notifications
You must be signed in to change notification settings - Fork 344
Read GUIDs from out parameters #1546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
62eb603
to
38f9bfe
Compare
Signed-off-by: Bradley Grainger <[email protected]>
38f9bfe
to
944ced6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR aims to fix issue #1528 by ensuring that GUID values are correctly read from OUT parameters. Key changes include adding a guidFormat parameter to several methods and constructors, updating the SQL payload generation for GUID columns, and revising tests to validate these changes.
Reviewed Changes
File | Description |
---|---|
tests/IntegrationTests/StoredProcedureTests.cs | Added StoredProcedureReturnsGuid tests with guidFormat parameter |
src/MySqlConnector/Core/SingleCommandPayloadCreator.cs | Adjusted out parameter handling for GUIDs with explicit casts |
src/MySqlConnector/Core/ColumnTypeMetadata.cs | Extended lookup keys to include the guidFormat parameter |
src/MySqlConnector/Core/TypeMapper.cs | Registered new GUID types with explicit guidFormat values |
src/MySqlConnector/Core/CachedProcedure.cs | Propagated guidFormat through parameter parsing and cached parameter creation |
src/MySqlConnector/ColumnReaders/ColumnReader.cs | Updated case handling for VarString/VarChar redirection |
tests/MySqlConnector.Tests/CachedProcedureTests.cs | Updated tests to include guidFormat for parameter parsing |
src/MySqlConnector/Core/CachedParameter.cs | Modified the constructor to accept and propagate guidFormat |
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
{ | ||
command.CommandType = CommandType.StoredProcedure; | ||
var param = new MySqlParameter("out_name", null) { Direction = ParameterDirection.Output }; | ||
if (mySqlDbType.HasValue && DateTime.UtcNow.Year == 2024) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a hard-coded year (2024) in the condition may cause tests to behave unexpectedly in future years. Consider replacing the DateTime.UtcNow.Year check with a configurable condition or removing it entirely.
if (mySqlDbType.HasValue && DateTime.UtcNow.Year == 2024) | |
var targetYear = int.Parse(Environment.GetEnvironmentVariable("TARGET_YEAR") ?? "2024"); | |
if (mySqlDbType.HasValue && DateTime.UtcNow.Year == targetYear) |
Copilot uses AI. Check for mistakes.
Signed-off-by: Bradley Grainger <[email protected]>
Signed-off-by: Bradley Grainger <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR addresses issue #1528 by adding support for reading GUIDs from OUT parameters. Key changes include new test cases for stored procedures using various GUID formats, updates to type mapping and lookup keys incorporating a new MySqlGuidFormat parameter, and corresponding modifications in parameter parsing and column reading logic.
Reviewed Changes
File | Description |
---|---|
tests/IntegrationTests/StoredProcedureTests.cs | New test cases for stored procedure GUID output handling |
src/MySqlConnector/Core/SingleCommandPayloadCreator.cs | Added special handling to cast GUID out parameters based on size and format |
src/MySqlConnector/Core/ColumnTypeMetadata.cs | Updated lookup key generation to include a GUID format component |
src/MySqlConnector/Core/TypeMapper.cs | Adjusted metadata addition and lookup to incorporate the new GUID format |
src/MySqlConnector/Core/CachedProcedure.cs | Modified parameter parsing and object creation to pass along GUID format |
src/MySqlConnector/ColumnReaders/ColumnReader.cs | Updated reader dispatch to use the correct case label for GUID types |
tests/MySqlConnector.Tests/CachedProcedureTests.cs | Updated test cases to include the GUID format parameter in inline data |
src/MySqlConnector/Core/CachedParameter.cs | Modified constructor to accept and pass the GUID format |
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/MySqlConnector/Core/TypeMapper.cs:200
- Ensure that the fallback TryGetValue call properly assigns columnTypeMetadata when a match is found. Consider checking the result of TryGetValue or using an 'if' block to validate the lookup for clarity.
if (length != 0) m_columnTypeMetadataLookup.TryGetValue(ColumnTypeMetadata.CreateLookupKey(columnTypeName, unsigned, 0, MySqlGuidFormat.Default), out columnTypeMetadata);
@bgrainger I think this has caused a breaking change for us. In version 2.4.0, a |
Edit: I misread your post. This should not be happening for |
Correct, a |
This reverts a change in #1546 that was introduced to fix #1528. However, none of the integration tests fail locally when reverting this change, so it's not clear why it was necessary. Signed-off-by: Bradley Grainger <[email protected]>
Fixes #1528